import { post } from '@/utils/request'

export const fetchProductionList = async (params) => {
  const url = `/api/admin/product/get_product_list?page_size=${params.page_size}&page_num=${params.page_num}`
  const res = await post(url, params)
  return res
}

export const fetchPlatformProductionList = async (params) => {
  const url = `/api/admin/product/get_platform_product_list?page_size=${params.page_size}&page_num=${params.page_num}`
  const res = await post(url, params)
  return res
}

// 商品上架,下架
export const fetchUpsAndDowns = (params) =>
  post('/api/admin/product/update_product_status', params)

// 平台商品 上下架
export const fetchPlatformUpsAndDowns = (params) =>
  post('/api/admin/product/update_platform_product_status', params)

// 创建商品
export const createProduct = async (params) => {
  const res = await post('/api/admin/product/create', params)
  return res
}

// 创建平台商品
export const createPlatformProduct = async (params) => {
  const res = await post('/api/admin/product/create_platform_product', params)
  return res
}

// 获取部门列表
export const getDeptList = async (params) => {
  const res = await post('/api/admin/account/get_dept_list', params)
  return res
}

// 商品详情
export const getProductDetail = async (params) => {
  const res = await post(`/api/admin/product/detail?id=${params.id}`, params)
  return res
}

// 平台商品详情
export const getPlatformProductDetail = async (params) => {
  const res = await post(`/api/admin/product/get_platform_product_detail?id=${params.id}`, params)
  return res
}

// 编辑商品
export const updateProduct = async (params) => {
  const res = await post(`/api/admin/product/update`, params)
  return res
}

// 编辑平台商品
export const updatePlatformProduct = async (params) => {
  const res = await post(`/api/admin/product/update_platform_product`, params)
  return res
}
